package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IConfigApp;
import com.itboye.mengwu.data.interfaces.IDingdanXiangQing;
import com.itboye.mengwu.data.model.AppConfigModel;
import com.itboye.mengwu.data.model.DingdanXiangQingBean;
import com.itboye.mengwu.data.repository.ConfigAppRepository;
import com.itboye.mengwu.data.repository.DingdanRepository;

public class ConfigAppPresenter extends BasePresenter implements
IConfigApp<AppConfigModel>{

	
	public static final String ConfigApp_success = MainPresenter.class
			.getName() + "_ConfigApp_success";
	public static final String ConfigAppFailEvent = MainPresenter.class
			.getName() + "_ConfigApp_fail";
	
	
	
	
	
	public static final String Guanzhu_success = MainPresenter.class
			.getName() + "_Guanzhu_success";
	public static final String GuanzhuFailEvent = MainPresenter.class
			.getName() + "_Guanzhu_fail";
	public ConfigAppPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(AppConfigModel model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delete(AppConfigModel model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(AppConfigModel model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void getInfo(AppConfigModel model) {
		// TODO Auto-generated method stub
		IConfigApp<AppConfigModel> carDelete = new ConfigAppRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ConfigApp_success);
						ConfigAppPresenter.this.setChanged();
						ConfigAppPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(ConfigAppFailEvent);
						ConfigAppPresenter.this.setChanged();
						ConfigAppPresenter.this.notifyObservers(result);
					}
				});

		carDelete.getInfo(model);
		
	}

	@Override
	public List<AppConfigModel> query(AppConfigModel model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getGuanZhu(String uid,String fromUid) {
		// TODO Auto-generated method stub
		IConfigApp<AppConfigModel> carDelete = new ConfigAppRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Guanzhu_success);
						ConfigAppPresenter.this.setChanged();
						ConfigAppPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(GuanzhuFailEvent);
						ConfigAppPresenter.this.setChanged();
						ConfigAppPresenter.this.notifyObservers(result);
					}
				});

		carDelete.getGuanZhu(uid, fromUid);
	}


}
